From 3f48bce7da3ec61b97aede34d54582312f1f37ff Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 8 Nov 2019 01:09:34 +0300 Subject: [PATCH] engine: client: fix #79 --- engine/client/cl_game.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index fb49bc6c..b39a3d8b 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -890,6 +890,7 @@ Render crosshair void CL_DrawCrosshair( void ) { int x, y, width, height; + float xscale, yscale; if( !clgame.ds.pCrosshair || !cl_crosshair->value ) return; @@ -902,7 +903,7 @@ void CL_DrawCrosshair( void ) width = clgame.ds.rcCrosshair.right - clgame.ds.rcCrosshair.left; height = clgame.ds.rcCrosshair.bottom - clgame.ds.rcCrosshair.top; - x = clgame.viewport[0] + ( clgame.viewport[2] >> 1 ); + x = clgame.viewport[0] + ( clgame.viewport[2] >> 1 ); y = clgame.viewport[1] + ( clgame.viewport[3] >> 1 ); // g-cont - cl.crosshairangle is the autoaim angle. @@ -922,16 +923,21 @@ void CL_DrawCrosshair( void ) y += ( clgame.viewport[3] >> 1 ) * screen[1] + 0.5f; } + // back to logical sizes + xscale = (float)clgame.scrInfo.iWidth / refState.width; + yscale = (float)clgame.scrInfo.iHeight / refState.height; + + x *= xscale; + y *= yscale; + // move at center the screen x -= 0.5f * width; y -= 0.5f * height; clgame.ds.pSprite = clgame.ds.pCrosshair; - *(int *)clgame.ds.spriteColor = *(int *)clgame.ds.rgbaCrosshair; + Vector4Copy( clgame.ds.rgbaCrosshair, clgame.ds.spriteColor ); - SPR_EnableScissor( x, y, width, height ); pfnSPR_DrawHoles( 0, x, y, &clgame.ds.rcCrosshair ); - SPR_DisableScissor(); } /*