engine: client: validate vid_rotate cvar value and save current rotation to ref global

This commit is contained in:
Alibek Omarov
2025-10-19 06:27:10 +05:00
parent 684f7fb75e
commit b8f0a89846
2 changed files with 9 additions and 0 deletions

View File

@@ -30,6 +30,8 @@ struct ref_state_s
// depends on build configuration
const char **short_names;
const char **long_names;
ref_screen_rotation_t rotation;
};
extern struct ref_state_s ref;

View File

@@ -143,6 +143,9 @@ void VID_SetDisplayTransform( int *render_w, int *render_h )
{
uint rotate = vid_rotate.value;
if( rotate < REF_ROTATE_NONE || rotate > REF_ROTATE_CCW )
rotate = REF_ROTATE_NONE;
if( ref.dllFuncs.R_SetDisplayTransform( rotate, 0, 0, vid_scale.value, vid_scale.value ))
{
if( rotate & 1 )
@@ -155,10 +158,14 @@ void VID_SetDisplayTransform( int *render_w, int *render_h )
*render_h /= vid_scale.value;
*render_w /= vid_scale.value;
ref.rotation = rotate;
}
else
{
Con_Printf( S_WARN "failed to setup screen transform\n" );
ref.rotation = REF_ROTATE_NONE;
}
}