Permalink
Browse files

Address PR comments

  • Loading branch information...
1 parent 9f669a8 commit 856ab46b77d16c913236392311af940731709aff @TimePath TimePath committed Feb 9, 2016
Oops, something went wrong.
Oops, something went wrong.
@@ -1435,7 +1435,7 @@ void ByteToDir( int b, vec3_t dir );
#define MAX_TOKENLENGTH 1024
//token types
-enum {
+enum class tokenType_t {
TT_STRING, // string
TT_LITERAL, // literal
TT_NUMBER, // number
@@ -1445,7 +1445,7 @@ enum {
struct pc_token_t
{
- int type;
+ tokenType_t type;
int subtype;
int intvalue;
float floatvalue;
@@ -473,7 +473,6 @@ qhandle_t RE_RegisterAnimation( const char *name )
qhandle_t hAnim;
skelAnimation_t *anim;
char *buffer;
- int bufferLen;
bool loaded = false;
if ( !name || !name[ 0 ] )
@@ -520,7 +519,7 @@ qhandle_t RE_RegisterAnimation( const char *name )
R_SyncRenderThread();
// load and parse the .md5anim file
- bufferLen = ri.FS_ReadFile( name, ( void ** ) &buffer );
+ int bufferLen = ri.FS_ReadFile( name, ( void ** ) &buffer );
if ( !buffer )
{
@@ -587,7 +586,7 @@ void R_AnimationList_f()
Log::Notice("'%s'", anim->name );
}
- Log::Warn("%8i : Total animations", tr.numAnimations );
+ Log::Notice("%8i : Total animations", tr.numAnimations );
}
/*
@@ -390,12 +390,6 @@ ChopWindingBehindPlane()
clips a winding to the fragment behind the plane
*/
-enum {
- SIDE_FRONT,
- SIDE_BACK,
- SIDE_ON,
-};
-
static void ChopWindingBehindPlane( int numInPoints, vec3_t inPoints[ MAX_DECAL_VERTS ],
int *numOutPoints, vec3_t outPoints[ MAX_DECAL_VERTS ], vec4_t plane, vec_t epsilon )
{
@@ -404,7 +398,7 @@ static void ChopWindingBehindPlane( int numInPoints, vec3_t inPoints[ MAX_DECAL_
float *p1, *p2, *clip;
float d;
float dists[ MAX_DECAL_VERTS + 4 ];
- int sides[ MAX_DECAL_VERTS + 4 ];
+ planeSide_t sides[ MAX_DECAL_VERTS + 4 ];
int counts[ 3 ];
/* set initial count */
@@ -417,41 +411,41 @@ static void ChopWindingBehindPlane( int numInPoints, vec3_t inPoints[ MAX_DECAL_
}
/* determine sides for each point */
- counts[ SIDE_FRONT ] = 0;
- counts[ SIDE_BACK ] = 0;
- counts[ SIDE_ON ] = 0;
+ counts[ Util::ordinal(planeSide_t::SIDE_FRONT) ] = 0;
+ counts[ Util::ordinal(planeSide_t::SIDE_BACK) ] = 0;
+ counts[ Util::ordinal(planeSide_t::SIDE_ON) ] = 0;
for ( i = 0; i < numInPoints; i++ )
{
dists[ i ] = DotProduct( inPoints[ i ], plane ) - plane[ 3 ];
if ( dists[ i ] > epsilon )
{
- sides[ i ] = SIDE_FRONT;
+ sides[ i ] = planeSide_t::SIDE_FRONT;
}
else if ( dists[ i ] < -epsilon )
{
- sides[ i ] = SIDE_BACK;
+ sides[ i ] = planeSide_t::SIDE_BACK;
}
else
{
- sides[ i ] = SIDE_ON;
+ sides[ i ] = planeSide_t::SIDE_ON;
}
- counts[ sides[ i ] ]++;
+ counts[ Util::ordinal(sides[ i ]) ]++;
}
sides[ i ] = sides[ 0 ];
dists[ i ] = dists[ 0 ];
/* all points on front */
- if ( counts[ SIDE_BACK ] == 0 )
+ if ( counts[ Util::ordinal(planeSide_t::SIDE_BACK) ] == 0 )
{
return;
}
/* all points on back */
- if ( counts[ SIDE_FRONT ] == 0 )
+ if ( counts[ Util::ordinal(planeSide_t::SIDE_FRONT) ] == 0 )
{
*numOutPoints = numInPoints;
Com_Memcpy( outPoints, inPoints, numInPoints * sizeof( vec3_t ) );
@@ -464,13 +458,13 @@ static void ChopWindingBehindPlane( int numInPoints, vec3_t inPoints[ MAX_DECAL_
p1 = inPoints[ i ];
clip = outPoints[ *numOutPoints ];
- if ( sides[ i ] == SIDE_ON || sides[ i ] == SIDE_BACK )
+ if ( sides[ i ] == planeSide_t::SIDE_ON || sides[ i ] == planeSide_t::SIDE_BACK )
{
VectorCopy( p1, clip );
( *numOutPoints ) ++;
}
- if ( sides[ i + 1 ] == SIDE_ON || sides[ i + 1 ] == sides[ i ] )
+ if ( sides[ i + 1 ] == planeSide_t::SIDE_ON || sides[ i + 1 ] == sides[ i ] )
{
continue;
}
@@ -250,7 +250,7 @@ static bool PC_Expression_Parse( int handle, float *f )
token.floatvalue = -token.floatvalue;
}
- if ( token.type == TT_NUMBER )
+ if ( token.type == tokenType_t::TT_NUMBER )
{
if ( !expectingNumber )
{
@@ -420,7 +420,7 @@ bool PC_Float_Parse( int handle, float *f )
negative = true;
}
- if ( token.type != TT_NUMBER )
+ if ( token.type != tokenType_t::TT_NUMBER )
{
PC_SourceError( handle, "expected float but found %s", token.string );
return false;
@@ -545,7 +545,7 @@ bool PC_Int_Parse( int handle, int *i )
negative = true;
}
- if ( token.type != TT_NUMBER )
+ if ( token.type != tokenType_t::TT_NUMBER )
{
PC_SourceError( handle, "expected integer but found %s", token.string );
return false;
@@ -49,7 +49,7 @@ static bool expectToken( const char *s, pc_token_list **list, bool next )
AIValue_t AIBoxToken( const pc_token_stripped_t *token )
{
- if ( token->type == TT_STRING )
+ if ( token->type == tokenType_t::TT_STRING )
{
return AIBoxString( token->string );
}
@@ -369,7 +369,7 @@ static const struct AIOpMap_s
static AIOpType_t opTypeFromToken( pc_token_stripped_t *token )
{
- if ( token->type != TT_PUNCTUATION )
+ if ( token->type != tokenType_t::TT_PUNCTUATION )
{
return OP_NONE;
}
@@ -506,7 +506,7 @@ static AIValue_t *parseFunctionParameters( pc_token_list **list, int *nparams, i
while ( parse != parenEnd )
{
- if ( parse->token.type == TT_NUMBER || parse->token.type == TT_STRING )
+ if ( parse->token.type == tokenType_t::TT_NUMBER || parse->token.type == tokenType_t::TT_STRING )
{
numParams++;
}
@@ -545,7 +545,7 @@ static AIValue_t *parseFunctionParameters( pc_token_list **list, int *nparams, i
parse = parenBegin->next;
while ( parse != parenEnd )
{
- if ( parse->token.type == TT_NUMBER || parse->token.type == TT_STRING )
+ if ( parse->token.type == tokenType_t::TT_NUMBER || parse->token.type == tokenType_t::TT_STRING )
{
params[ numParams ] = AIBoxToken( &parse->token );
numParams++;
@@ -701,11 +701,11 @@ static AIExpType_t *Primary( pc_token_list **list )
return nullptr;
}
}
- else if ( current->token.type == TT_NUMBER )
+ else if ( current->token.type == tokenType_t::TT_NUMBER )
{
tree = ( AIExpType_t * ) newValueLiteral( list );
}
- else if ( current->token.type == TT_NAME )
+ else if ( current->token.type == tokenType_t::TT_NAME )
{
tree = ( AIExpType_t * ) newValueFunc( list );
}
@@ -43,7 +43,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
typedef struct
{
- int type;
+ tokenType_t type;
int subtype;
int intvalue;
float floatvalue;
@@ -317,7 +317,7 @@ static bool BG_VoiceParseTrack( int handle, voiceTrack_t *voiceTrack )
{
foundToken = trap_Parse_ReadToken( handle, &token );
- if ( token.type == TT_NUMBER )
+ if ( token.type == tokenType_t::TT_NUMBER )
{
voiceTrack->enthusiasm = token.intvalue;
}

0 comments on commit 856ab46

Please sign in to comment.