From b8f0a89846ad0f14d787aaf1da01e5b44054d399 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 19 Oct 2025 06:27:10 +0500 Subject: [PATCH] engine: client: validate vid_rotate cvar value and save current rotation to ref global --- engine/client/ref_common.h | 2 ++ engine/client/vid_common.c | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/engine/client/ref_common.h b/engine/client/ref_common.h index c5b15d14..679a32e7 100644 --- a/engine/client/ref_common.h +++ b/engine/client/ref_common.h @@ -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; diff --git a/engine/client/vid_common.c b/engine/client/vid_common.c index 1dbb11ae..b94f88f3 100644 --- a/engine/client/vid_common.c +++ b/engine/client/vid_common.c @@ -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; } }