@@ -106,10 +106,10 @@ bool CClientVariables::Get(const std::string& strVariable, CColor& val)
106106 try
107107 {
108108 ss >> iR >> iG >> iB >> iA;
109- val.R = iR ;
110- val.G = iG ;
111- val.B = iB ;
112- val.A = iA ;
109+ val.R = static_cast < unsigned char >(iR) ;
110+ val.G = static_cast < unsigned char >(iG) ;
111+ val.B = static_cast < unsigned char >(iB) ;
112+ val.A = static_cast < unsigned char >(iA) ;
113113 }
114114 catch (...)
115115 {
@@ -234,7 +234,15 @@ void CClientVariables::ValidateValues()
234234
235235 ClampValue (" console_pos" , CVector2D (0 , 0 ), CVector2D (uiViewportWidth - 32 , uiViewportHeight - 32 ));
236236 ClampValue (" console_size" , CVector2D (50 , 50 ), CVector2D (uiViewportWidth - 32 , uiViewportHeight - 32 ));
237- ClampValue (" fps_limit" , 0 , std::numeric_limits<short >::max ());
237+
238+ // CVars need a better API for this (Issue #4427)
239+ int temp;
240+ CVARS_GET (" fps_limit" , temp);
241+ std::uint16_t fps = static_cast <std::uint16_t >(temp);
242+ FPSLimits::IsValidAndSetValid (fps, fps);
243+ CVARS_SET (" fps_limit" , fps);
244+
245+
238246 ClampValue (" chat_font" , 0 , 3 );
239247 ClampValue (" chat_lines" , 3 , 62 );
240248 ClampValue (" chat_color" , CColor (0 , 0 , 0 , 0 ), CColor (255 , 255 , 255 , 255 ));
@@ -261,9 +269,10 @@ void CClientVariables::ValidateValues()
261269
262270void CClientVariables::LoadDefaults ()
263271{
264- #define DEFAULT (__x,__y ) if (!Exists(__x)) \
265- Set (__x,__y)
266- #define _S (__x ) std::string(__x)
272+ #define DEFAULT (__x, __y ) \
273+ if (!Exists (__x)) \
274+ Set (__x, __y)
275+ #define _S (__x ) std::string(__x)
267276
268277 if (!Exists (" nick" ))
269278 {
@@ -279,6 +288,7 @@ void CClientVariables::LoadDefaults()
279288 DEFAULT (" console_size" , CVector2D (200 , 200 )); // console size
280289 DEFAULT (" serverbrowser_size" , CVector2D (720 .0f , 495 .0f )); // serverbrowser size
281290 DEFAULT (" fps_limit" , 100 ); // frame limiter
291+ DEFAULT (" vsync" , true ); // vsync
282292 DEFAULT (" chat_font" , 2 ); // chatbox font type
283293 DEFAULT (" chat_lines" , 10 ); // chatbox lines
284294 DEFAULT (" chat_color" , CColor (0 , 0 , 0 , 0 )); // chatbox background color
@@ -379,4 +389,8 @@ void CClientVariables::LoadDefaults()
379389#if 0
380390 DEFAULT ( "streaming_memory", 50 ); // Streaming memory
381391#endif
392+
393+ #undef DEFAULT
394+ #undef _S
395+
382396}
0 commit comments