Skip to content
Permalink
Browse files

Rename the color struct to match the coding convention

  • Loading branch information...
mbasaglia committed Aug 4, 2015
1 parent 6e1705a commit e71e348e42eb9657d1be7695698f03cf36edf6a9
@@ -129,7 +129,7 @@ static const char *Con_LineToColouredString( int lineno, bool lf )
const conChar_t *line = consoleState.text + CON_LINE( lineno );
int s, d;

color_t colour(7);
color_s colour(7);

for ( s = d = 0; line[ s ].ch && s < consoleState.textWidthInChars; ++s )
{
@@ -200,7 +200,7 @@ Con_Clear
static INLINE void Con_Clear()
{
int i;
conChar_t fill = { '\0', color_t( CONSOLE_COLOR ) };
conChar_t fill = { '\0', color_s( CONSOLE_COLOR ) };

for ( i = 0; i < CON_TEXTSIZE; ++i )
{
@@ -540,7 +540,7 @@ void Con_Linefeed()
{
int i;
conChar_t *line;
const conChar_t blank = { 0, color_t( CONSOLE_COLOR ) };
const conChar_t blank = { 0, color_s( CONSOLE_COLOR ) };
const int scrollLockMode = con_scrollLock ? con_scrollLock->integer : 0;

consoleState.horizontalCharOffset = 0;
@@ -618,13 +618,13 @@ bool CL_InternalConsolePrint( const char *text )
cgvm.CGameConsoleLine( text );
}

color_t color( CONSOLE_COLOR );
color_s color( CONSOLE_COLOR );

while ( ( c = *text & 0xFF ) != 0 )
{
if ( Q_IsColorString( text ) )
{
color = color_t( text[ 1 ] == COLOR_NULL ? CONSOLE_COLOR : text[ 1 ] );
color = color_s( text[ 1 ] == COLOR_NULL ? CONSOLE_COLOR : text[ 1 ] );
text += 2;
continue;
}
@@ -1035,8 +1035,8 @@ void Con_DrawConsoleContent()
++row;
}

color_t currentColor(7);
color_t color = currentColor;
color_s currentColor(7);
color_s color = currentColor;

for ( ; row >= 0 && lineDrawPosition > textDistanceToTop; lineDrawPosition -= charHeight, row-- )
{
@@ -1067,7 +1067,7 @@ void Con_DrawConsoleContent()
color = currentColor;
}

color.a = color_t::limits_type::max() *
color.a = color_s::limits_type::max() *
Con_MarginFadeAlpha( consoleState.currentAlphaFactor, lineDrawPosition, textDistanceToTop, lineDrawLowestPosition, charHeight );
re.SetColor( color );

@@ -285,11 +285,11 @@ Coordinates are at 640 by 480 virtual resolution

void SCR_DrawStringExt( int x, int y, float size, const char *string, float *setColor, bool forceColor, bool noColorEscape )
{
color_t color;
color_s color;
const char *s;
int xx;
bool noColour = false;
color_t::component_type alpha = setColor[ 3 ] * color_t::limits_type::max();
color_s::component_type alpha = setColor[ 3 ] * color_s::limits_type::max();

// draw the drop shadow
color.a = alpha;
@@ -330,11 +330,11 @@ void SCR_DrawStringExt( int x, int y, float size, const char *string, float *set
{
if ( * ( s + 1 ) == COLOR_NULL )
{
color = color_t( setColor );
color = color_s( setColor );
}
else
{
color = color_t( s[ 1 ] );
color = color_s( s[ 1 ] );
}

color.a = alpha;
@@ -413,11 +413,11 @@ Coordinates are at 640 by 480 virtual resolution
*/
void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor, bool forceColor, bool noColorEscape )
{
color_t color;
color_s color;
const char *s;
float xx;
bool noColour = false;
color_t::component_type alpha = setColor[ 3 ] * color_t::limits_type::max();
color_s::component_type alpha = setColor[ 3 ] * color_s::limits_type::max();

// draw the colored text
s = string;
@@ -436,11 +436,11 @@ void SCR_DrawSmallStringExt( int x, int y, const char *string, float *setColor,
{
if ( * ( s + 1 ) == COLOR_NULL )
{
color = color_t( setColor );
color = color_s( setColor );
}
else
{
color = color_t( s[ 1 ] );
color = color_s( s[ 1 ] );
}

color.a = alpha;
@@ -715,7 +715,7 @@ bool CL_UpdateVisiblePings_f( int source );
struct conChar_t
{
int ch;
color_t ink;
color_s ink;
};

typedef struct
@@ -109,7 +109,7 @@ void RE_AddPolysToScene( qhandle_t hShader, int numVerts, const polyVert_t *vert
void RE_AddLightToScene( const vec3_t org, float radius, float intensity, float r, float g, float b, qhandle_t hShader, int flags ) { }
void RE_AddLightToSceneQ3A( const vec3_t org, float intensity, float r, float g, float b ) { }
void RE_RenderScene( const refdef_t *fd ) { }
void RE_SetColor( const color_t& rgba ) { }
void RE_SetColor( const color_s& rgba ) { }
void RE_SetClipRegion( const float *region ) { }
void RE_StretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ) { }
void RE_RotatedPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, float angle ) { }
@@ -176,71 +176,71 @@ inline bool Q_IsHexColorString( const char *p )

/*
================
color_t
color_s
Simple wrapper around vec4_t
================
*/
struct color_t
struct color_s
{
typedef unsigned char component_type;
typedef std::numeric_limits<component_type> limits_type;
component_type r = 0, g = 0, b = 0, a = 0;

/*
================
color_t::color_t
color_s::color_s
Initialize from a color index
================
*/
explicit color_t(int index)
explicit color_s(int index)
{
if ( index >= 0 && index < 32 )
assign_float_array( g_color_table[index] );
}

/*
================
color_t::color_t
color_s::color_s
Initialize from a color index character
================
*/
explicit color_t(char index)
: color_t( int( ColorIndex(index) ) )
explicit color_s(char index)
: color_s( int( ColorIndex(index) ) )
{
}

/*
================
color_t::color_t
color_s::color_s
Initialize from a float array
================
*/
color_t(const float array[4])
color_s(const float array[4])
{
assign_float_array(array);
}

/*
================
color_t::color_t
color_s::color_s
Default constructor, all components set to zero
================
*/
constexpr color_t() = default;
constexpr color_s() = default;

/*
================
color_t::color_t
color_s::color_s
Default constructor, all components set to zero
================
*/
constexpr color_t(component_type r, component_type g, component_type b,
constexpr color_s(component_type r, component_type g, component_type b,
component_type a = limits_type::max())
: r(r), g(g), b(b), a(a)
{
@@ -256,12 +256,12 @@ struct color_t
return reinterpret_cast<const component_type*>(this)[index];
}*/

bool operator==( const color_t& other ) const
bool operator==( const color_s& other ) const
{
return integer_32bit() == other.integer_32bit();
}

bool operator!=( const color_t& other ) const
bool operator!=( const color_s& other ) const
{
return integer_32bit() != other.integer_32bit();
}
@@ -292,7 +292,7 @@ struct color_t

/*
================
color_t::integer_32bit
color_s::integer_32bit
Returns a 32bit integer representing the color,
no guarantees are made with respect to endianness
@@ -311,14 +311,14 @@ ColorFromHexString
Creates a color from a string, assumes Q_IsHexColorString(p)
================
*/
inline color_t ColorFromHexString( const char* p )
inline color_s ColorFromHexString( const char* p )
{
// Note: [0-15]*17 = [0-255]
return {
color_t::component_type(gethex(p[2])*17),
color_t::component_type(gethex(p[3])*17),
color_t::component_type(gethex(p[4])*17),
color_t::limits_type::max()
color_s::component_type(gethex(p[2])*17),
color_s::component_type(gethex(p[3])*17),
color_s::component_type(gethex(p[4])*17),
color_s::limits_type::max()
};
}

@@ -300,7 +300,7 @@ RE_SetColor
Passing nullptr will set the color to white
=============
*/
void RE_SetColor( const color_t& rgba )
void RE_SetColor( const color_s& rgba )
{
setColorCommand_t *cmd;

@@ -3903,7 +3903,7 @@ static inline void halfToFloat( const f16vec4_t in, vec4_t out )

void R_AddDrawViewCmd();

void RE_SetColor( const color_t& rgba );
void RE_SetColor( const color_s& rgba );
void R_AddRunVisTestsCmd();
void RE_SetClipRegion( const float *region );
void RE_StretchPic( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader );
@@ -105,7 +105,7 @@ typedef struct

void ( *RenderScene )( const refdef_t *fd );

void ( *SetColor )( const color_t& rgba ); // nullptr = 1,1,1,1
void ( *SetColor )( const color_s& rgba ); // nullptr = 1,1,1,1
void ( *SetClipRegion )( const float *region );
void ( *DrawStretchPic )( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader ); // 0 = white
void ( *DrawRotatedPic )( float x, float y, float w, float h, float s1, float t1, float s2, float t2, qhandle_t hShader, float angle ); // NERVE - SMF

0 comments on commit e71e348

Please sign in to comment.
You can’t perform that action at this time.