Skip to content

Commit

Permalink
[MP/SP] Fix rendering of radar arrows
Browse files Browse the repository at this point in the history
This bug was unintentionally introduced during the fixing of RB_RotatePic similar to the bug previously introduced with rocket lock wedges. The arrow for players on the radar contain `rgbGen identity` which does not work with setting 2d color (trap->SetColor) but due to how the code previously worked, it rendered correctly.

Fixes #910
  • Loading branch information
ensiform committed Feb 23, 2017
1 parent 7b5f79a commit 47df6ee
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions code/rd-vanilla/tr_shader.cpp
Expand Up @@ -42,6 +42,10 @@ static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS];
// retail JKA shader for gfx/2d/wedge.
#define RETAIL_ROCKET_WEDGE_SHADER_HASH (1217042)

// Hash value (generated using the generateHashValueForText function) for the original
// retail JKA shader for gfx/menus/radar/arrow_w.
#define RETAIL_ARROW_W_SHADER_HASH (1650186)


#define FILE_HASH_SIZE 1024
static shader_t* sh_hashTable[FILE_HASH_SIZE];
Expand Down Expand Up @@ -2461,6 +2465,21 @@ Ghoul2 Insert End
stages[0].stateBits |= GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;
}

// The basejka radar arrow contains an incorrect rgbGen of identity
// It only worked because the original code didn't check shaders at all,
// thus setcolor worked fine but with fixing RB_RotatePic it no longer
// functioned because rgbGen identity doesn't work with setcolor.
//
// We match against retail version of gfx/menus/radar/arrow_w by calculating
// the hash value of the shader text, and comparing it against a
// precalculated value.
if ( shaderHash == RETAIL_ARROW_W_SHADER_HASH &&
Q_stricmp( shader.name, "gfx/menus/radar/arrow_w" ) == 0 )
{
stages[0].rgbGen = CGEN_VERTEX;
stages[0].alphaGen = AGEN_VERTEX;
}

COM_EndParseSession();
return qtrue;
}
Expand Down
19 changes: 19 additions & 0 deletions codemp/rd-vanilla/tr_shader.cpp
Expand Up @@ -37,6 +37,10 @@ static texModInfo_t texMods[MAX_SHADER_STAGES][TR_MAX_TEXMODS];
// retail JKA shader for gfx/2d/wedge.
#define RETAIL_ROCKET_WEDGE_SHADER_HASH (1217042)

// Hash value (generated using the generateHashValueForText function) for the original
// retail JKA shader for gfx/menus/radar/arrow_w.
#define RETAIL_ARROW_W_SHADER_HASH (1650186)

#define FILE_HASH_SIZE 1024
static shader_t* hashTable[FILE_HASH_SIZE];

Expand Down Expand Up @@ -2363,6 +2367,21 @@ static qboolean ParseShader( const char **text )
stages[0].stateBits |= GLS_SRCBLEND_SRC_ALPHA | GLS_DSTBLEND_ONE_MINUS_SRC_ALPHA;
}

// The basejka radar arrow contains an incorrect rgbGen of identity
// It only worked because the original code didn't check shaders at all,
// thus setcolor worked fine but with fixing RB_RotatePic it no longer
// functioned because rgbGen identity doesn't work with setcolor.
//
// We match against retail version of gfx/menus/radar/arrow_w by calculating
// the hash value of the shader text, and comparing it against a
// precalculated value.
if ( shaderHash == RETAIL_ARROW_W_SHADER_HASH &&
Q_stricmp( shader.name, "gfx/menus/radar/arrow_w" ) == 0 )
{
stages[0].rgbGen = CGEN_VERTEX;
stages[0].alphaGen = AGEN_VERTEX;
}

return qtrue;
}

Expand Down

0 comments on commit 47df6ee

Please sign in to comment.