MantisBT - Zandronum
View Issue Details
0002029Zandronum[All Projects] Bugpublic2014-12-19 20:412016-02-13 22:11
Ch0wW 
Torr Samaho 
normalminoralways
needs reviewopen 
1.3 
 
0002029: "Draw Coop Infos" and weirdness/optimisations
As a spectator, using "Coop Infos" (or Sitrep) on CTF games has unwanted elements readable.

For instance, the Ammo. When spectating someone in his "eyes", you have no info about his ammo. However, with the coop infos, ammo is displayed. So either display his ammo, or just don't display it at all?

1) Play CTF or any competitive gamemode.
2) Be a spectator and don't spec someone's eyes.
3) Check "Coop Infos"
4) Ammo is readable.

Also, optimising space, by not showing ???/??? on competitive gamemodes should be done. Wasting space for useless text isn't really wanted.
abuse, ammo, camera, info, spectator
png Screenshot_Doom_20141219_211546.png (214,848) 2014-12-20 02:11
/tracker/file_download.php?file_id=1348&type=bug
png

png Screenshot_Doom_20141219_211551.png (352,459) 2014-12-20 02:11
/tracker/file_download.php?file_id=1349&type=bug
Issue History
2014-12-19 20:41Ch0wWNew Issue
2014-12-20 02:11Ch0wWFile Added: Screenshot_Doom_20141219_211546.png
2014-12-20 02:11Ch0wWFile Added: Screenshot_Doom_20141219_211551.png
2014-12-21 16:56WatermelonNote Added: 0011081
2014-12-21 16:56WatermelonStatusnew => acknowledged
2014-12-22 11:34Ch0wWNote Added: 0011084
2014-12-22 17:43Ch0wWNote Edited: 0011084bug_revision_view_page.php?bugnote_id=11084#r6154
2014-12-28 16:10Torr SamahoAssigned To => Torr Samaho
2014-12-28 16:10Torr SamahoStatusacknowledged => needs review
2016-02-13 22:11Ch0wWNote Added: 0014433

Notes
(0011081)
Watermelon   
2014-12-21 16:56   
The HUD is sadly a mess and in need of re-working. I'll be overhauling a lot of it with the new scoreboard that will have to rip apart the HUD.

If you have any graphical ideas you should post them as to what it should look like.
(0011084)
Ch0wW   
2014-12-22 11:34   
(edited on: 2014-12-22 17:43)
Here is a DrawHUD_CoopInfo() optimisation code, with the ammo fixed, but I don't think it is complete.

It now does the following:

- Check the following gamemode, to check if the server has a "casual" gamemode (ie: coop/survival/invasion).

- Do NOT display health if we're not in a casual gamemode. However, players within a team can still see them, or if the server allows to see player's health as a spectator.

- Do NOT display ammo if we're not in a casual gamemode. However, display still his weapon or if he's dead (or not, if the server allows to see player's health as a spectator)

'http://pastebin.com/ae3AgHXj [^]'

EDIT: SCREENSHOTS:

'http://image.noelshack.com/fichiers/2014/52/1419270058-screenshot-doom-20141222-183122.png [^]'
'http://image.noelshack.com/fichiers/2014/52/1419270057-screenshot-doom-20141222-183948.png [^]'
'http://image.noelshack.com/fichiers/2014/52/1419270058-screenshot-doom-20141222-184023.png [^]'

(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++;
    }
}