@@ -299,24 +299,21 @@ namespace Components
299299
300300 void QuickPatch::CL_InitRef_Hk (Game::GfxConfiguration* config)
301301 {
302- // CL_InitRef() initializes a GfxConfiguration with `defaultFullscreen` set to true.
303- // This configuration is passed to R_ConfigureRenderer(), which copies it to the global `gfxCfg` structure.
304- // In R_RegisterDvars(), r_fullscreen is registered using the value from `gfxCfg.defaultFullscreen` as default.
305-
306- // By overriding `defaultFullscreen` before R_ConfigureRenderer() calls R_RegisterDvars(),
307- // we can force the game to start in windowed mode on first launch.
302+ // CL_InitRef() creates a GfxConfiguration with defaultFullscreen = true,
303+ // which r_fullscreen inherits as the default value. We override the field
304+ // here to force windowed startup on first launch.
308305 config->defaultFullscreen = false ;
309306
310307 // Call original R_ConfigureRenderer()
311- return Utils::Hook::Call<void ( const Game::GfxConfiguration * config)>(0x508040 )(config);
308+ return Utils::Hook::Call<void ( Game::GfxConfiguration* config)>(0x508040 )(config);
312309 }
313310
314311 void QuickPatch::R_EnumDisplayModes_Hk (unsigned int adapterIndex)
315312 {
316313 // Call original R_EnumDisplayModes() to let it register and save available display modes in r_mode
317314 Utils::Hook::Call<void (unsigned int adapterIndex)>(0x506F10 )(adapterIndex);
318315
319- if (Dvar::Var (" g_firstLaunch" ).get <bool > () == false )
316+ if (Dvar::Var (" g_firstLaunch" ).get <bool >() == false )
320317 {
321318 return ;
322319 }
@@ -328,7 +325,8 @@ namespace Components
328325
329326 // Get the resolution of the monitor that will be used for the game
330327 HMONITOR adapterMonitor = (*Game::d3d9)->GetAdapterMonitor (adapterIndex);
331- MONITORINFO mi (sizeof (MONITORINFO));
328+ MONITORINFO mi{};
329+ mi.cbSize = sizeof (MONITORINFO);
332330
333331 if (!GetMonitorInfoA (adapterMonitor, &mi))
334332 {
@@ -338,15 +336,13 @@ namespace Components
338336 const int monitor_width = mi.rcMonitor .right - mi.rcMonitor .left ;
339337 const int monitor_height = mi.rcMonitor .bottom - mi.rcMonitor .top ;
340338
341- // Now we can match the monitor resolution to one of the available r_mode strings
342- Game::dvar_t * r_mode = Game::Dvar_FindVar (" r_mode" );
339+ Game::dvar_t * r_mode = Game::Dvar_FindVar (" r_mode" );
343340
344341 if (!r_mode || !r_mode->domain .enumeration .strings || r_mode->domain .enumeration .stringCount <= 0 )
345342 {
346343 return ;
347344 }
348345
349- // game has already selected the mode it believes is best
350346 int mode_index = r_mode->current .integer ;
351347 int mode_width = 0 ;
352348 int mode_height = 0 ;
@@ -365,13 +361,9 @@ namespace Components
365361 }
366362 }
367363
368- // Set r_mode to the resolution that matches the current monitor.
369- // Note that this dvar is registered with 2 flags: DVAR_ARCHIVE and DVAR_LATCH.
370- // To ensure the change propagates correctly, we use an API call instead of modifying the dvar directly.
371364 Game::Dvar_SetInt (r_mode, mode_index);
372365
373- // Also make sure the window is positioned at the top-left corner.
374- // This will give us a fullscreen-like appearance
366+ // Move the window to the top-left corner for a fullscreen-like appearance
375367 Game::dvar_t * vid_xpos = Game::Dvar_FindVar (" vid_xpos" );
376368 Game::dvar_t * vid_ypos = Game::Dvar_FindVar (" vid_ypos" );
377369 if (vid_xpos) Game::Dvar_SetInt (vid_xpos, 0 );
0 commit comments