diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index 617e421..ec15d1a 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -526,16 +526,17 @@ void CHudHealth :: DrawPlayerLocation( void ) void CHudHealth :: DrawRadarDot(int x, int y, int size, int r, int g, int b, int a) { - FillRGBA( x - size/2, y - size/2, size, size, r, g, b, a); + FillRGBA(62.5+ x - size/2,62.5+ y - size/2, size, size, r, g, b, a); } void CHudHealth :: DrawRadar( float flTime ) { char szTeamName[16]; - int localPlayer = gHUD.m_Scoreboard.m_iPlayerNum; - vec3_t localPlayerOrigin = gHUD.m_vecOrigin; - strncpy(szTeamName, g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamname, sizeof(szTeamName) ); + if( g_PlayerExtraInfo[ gHUD.m_Scoreboard.m_iPlayerNum ].dead ) + return; + + strncpy( szTeamName, g_PlayerExtraInfo[ gHUD.m_Scoreboard.m_iPlayerNum ].teamname, 16 ); if( cl_radartype->value ) { @@ -547,23 +548,25 @@ void CHudHealth :: DrawRadar( float flTime ) SPR_Set( m_hRadar, 25, 75, 25 ); SPR_DrawAdditive( 0, 0, 0, &m_hrad ); } - - // players + bomb - for( int i = 0; i < 34; i++ ) + for(int i=0; i<35;i++) { - // skip other players and local client - if( strcmp(g_PlayerExtraInfo[i].teamname, szTeamName) || gHUD.m_Scoreboard.m_iPlayerNum == i ) + char debuginfo[1024]; + if( i == gHUD.m_Scoreboard.m_iPlayerNum || strncmp( szTeamName, g_PlayerExtraInfo[i].teamname, 16 ) || g_PlayerExtraInfo[i].dead ) continue; - - vec3_t pOrigin = g_PlayerExtraInfo[i].origin; - Vector2D delta( pOrigin.x - gHUD.m_vecOrigin.x, pOrigin.y - gHUD.m_vecOrigin.y ); - float rotateangle = atan(-delta.y / delta.x) * 180.0f / M_PI; - - rotateangle += gHUD.m_vecAngles.y; - double x, y; - sincos( rotateangle * M_PI / 180.0f, &x, &y ); - - DrawRadarDot( (m_hrad.right - m_hrad.left) / 2 + delta.x * x, (m_hrad.bottom - m_hrad.top) / 2 + delta.y * y, 10, 255, 255, 255, 120); + float rel_x = gHUD.m_vecOrigin.x - g_PlayerExtraInfo[i].origin.x; + float rel_y = gHUD.m_vecOrigin.y - g_PlayerExtraInfo[i].origin.y; + float plAngle = atanf( rel_x/rel_y ) * 180.0 / 3.141592654;\ + //plAngle = fmod( plAngle, 360 ); + //if(plAngle < 0) + //plAngle += 360; + float azim = ( plAngle - gHUD.m_vecAngles.y ) * 3.141592654 / 180.0; + //azim= fmod( azim, 3.141592654 ); + //if( azim < 0 ) + //azim += 3.141592654; + float relabs = sqrtf( rel_x*rel_x + rel_y*rel_y ); + sprintf(debuginfo, "rx%f ry%f pa%f a%f ra%f\n", rel_x, rel_y, plAngle, azim, relabs ); + ConsolePrint( debuginfo ); + DrawRadarDot( cos(azim)*relabs * 0.03125, sin(azim)*relabs * 0.03125, 5, 0, 255, 0, 255 ); } } diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index e7eae80..c99e428 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -261,7 +261,7 @@ int CHud :: DrawHudStringLen( char *szIt ) int CHud :: DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b ) { char szString[32]; - sprintf( szString, "%d", iNumber ); + snprintf( szString, 32, "%d", iNumber ); return DrawHudStringReverse( xpos, ypos, iMinX, szString, r, g, b ); }