(0011084)
|
Ch0wW
|
2014-12-22 11:34
(edited on: 2014-12-22 17:43) |
|
|
(0014433)
|
Ch0wW
|
2016-02-13 22:11
|
|
Looks like my previous patch didn't fix a rare case where everyone could see life and armor, aswell as ammo.
Here's the real fix.
// Ch0wW: Fixed view (issue:'https://zandronum.com/tracker/view.php?id=2029 [^]' )
void DrawHUD_CoopInfo()
{
// [BB] Only draw the info if the user wishes to see it (cl_drawcoopinfo)
// and if this is a cooperative or team based game mode. Further don't draw this in single player.
if ( ( cl_drawcoopinfo == false ) || ( zadmflags & ZADF_NO_COOP_INFO )
|| ! ( (GAMEMODE_GetFlags( GAMEMODE_GetCurrentMode( )) & GMF_COOPERATIVE)
|| (GAMEMODE_GetFlags( GAMEMODE_GetCurrentMode( )) & GMF_PLAYERSONTEAMS) )
|| NETWORK_GetState() == NETSTATE_SINGLE )
return;
const bool bScale = HUD_IsScaled();
bool bCanSeeLife;
FString drawString;
// [BB] We may not draw in the first 4 lines, this is reserved for chat messages.
// Leave free another line to prevent the keys from being drawn over in ST's
// fullscreen HUD.
// [Dusk] Said message field can now have an arbitrary amount of lines, so
// we cannot assume the default 4.
const int yOffset = ( 1 + con_notifylines ) * SmallFont->GetHeight( );
int playersDrawn = 0;
for ( int i = 0; i < MAXPLAYERS; i++ )
{
// [BB] Only draw the info of players who are actually in the game.
if ( (playeringame[i] == false) || ( players[i].bSpectating ) || (players[i].mo == NULL) )
continue;
// [BB] No need to draw the info of the player who's eyes we are looking through.
if ( players[i].mo->CheckLocalView( consoleplayer ) )
continue;
// [BB] Only display team mates (in coop all players are team mates). Spectators see everybody.
if ( players[consoleplayer].camera && !players[consoleplayer].camera->IsTeammate ( players[i].mo )
&& !( players[consoleplayer].camera->player && players[consoleplayer].camera->player->bSpectating ) )
continue;
// [BB] We need more spacing if there is SECTINFO.
int curYPos = yOffset + (playersDrawn/2) * ( ( 4 + ( level.info->SectorInfo.Names.Size() > 0 ) ) * SmallFont->GetHeight( ) + 3 ) ;
const bool drawLeft = ( playersDrawn % 2 == 0 );
// [BB] Draw player name.
drawString = players[i].userinfo.netname;
V_ColorizeString( drawString );
EColorRange nameColor = CR_GREY;
// [BB] If the player is on a team, use the team's text color.
if ( GAMEMODE_GetFlags( GAMEMODE_GetCurrentMode( )) & GMF_PLAYERSONTEAMS )
nameColor = static_cast<EColorRange> ( TEAM_GetTextColor ( players[i].ulTeam ) );
HUD_DrawTextAligned ( nameColor, curYPos, drawString.GetChars(), drawLeft, bScale );
curYPos += SmallFont->GetHeight( ) + 1;
// [BL] Draw the player's location, [BB] but only if the map has any SectorInfo.
if ( level.info->SectorInfo.Names.Size() > 0 )
{
drawString = SECTINFO_GetPlayerLocation( i );
V_ColorizeString( drawString );
HUD_DrawTextAligned ( CR_GREY, curYPos, drawString.GetChars(), drawLeft, bScale );
curYPos += SmallFont->GetHeight( ) + 1;
}
//============= NEW PART
// Ch0wW -- Health indicator is only seen for players, OR if the server allows knowing life.
if (SERVER_IsPlayerAllowedToKnowHealth( consoleplayer, i))
{
// [BB] Draw player health (color coded) and armor.
EColorRange healthColor = CR_RED;
// [BB] Player is alive.
if ( players[i].mo->health <= 0 )
drawString = "dead";
else
{
AInventory* pArmor = players[i].mo->FindInventory(RUNTIME_CLASS(ABasicArmor));
drawString.Format( "%d \\cD/ %d", players[i].mo->health, pArmor ? pArmor->Amount : 0 );
V_ColorizeString( drawString );
if ( players[i].mo->health > 66 )
healthColor = CR_GREEN;
else if ( players[i].mo->health > 33 )
healthColor = CR_GOLD;
}
HUD_DrawTextAligned ( healthColor, curYPos, drawString.GetChars(), drawLeft, bScale );
curYPos += SmallFont->GetHeight( ) + 1;
// [BB] Draw player weapon and Ammo1/Ammo2, but only if the player is alive.
// [Spleen] And don't draw ammo if sv_infiniteammo is enabled.
// Ch0wW -- Rewriting for DrawCoopinfo patch:
// >> If we're in a casual gamemode or that we're a player, you can get info from your friends
if (players[i].ReadyWeapon && players[i].mo->health > 0)
{
drawString = players[i].ReadyWeapon->GetClass()->TypeName;
if ( players[i].ReadyWeapon->Ammo1 && ( ( dmflags & DF_INFINITE_AMMO ) == false ) )
drawString.AppendFormat( " \\cf%d", players[i].ReadyWeapon->Ammo1->Amount );
else
drawString += " \\cg-";
if ( players[i].ReadyWeapon->Ammo2 && ( ( dmflags & DF_INFINITE_AMMO ) == false ) )
drawString.AppendFormat( " \\cf%d", players[i].ReadyWeapon->Ammo2->Amount );
V_ColorizeString( drawString );
HUD_DrawTextAligned ( CR_GREEN, curYPos, drawString.GetChars(), drawLeft, bScale );
}
}
else // Ch0wW -- ELSE, in competitive and as a spectator, know only his weapon OR if he's dead...
{
if (players[i].ReadyWeapon)
{
EColorRange healthColor = CR_GREEN;
if (players[i].mo->health > 0)
drawString = players[i].ReadyWeapon->GetClass()->TypeName;
// If he's dead, simply put "dead" (or nothing, depending of the DMFLAGS) ...
else if ( players[i].mo->health <= 0 ) {
healthColor = CR_RED;
drawString = "dead";
}
V_ColorizeString( drawString );
HUD_DrawTextAligned ( healthColor, curYPos, drawString.GetChars(), drawLeft, bScale );
}
}
playersDrawn++;
}
}
|
|