engine: use designated initializers where possible

This commit is contained in:
Alibek Omarov
2026-05-20 12:44:26 -04:00
committed by a1batross
parent c5a8160c32
commit 64be4251c8
15 changed files with 143 additions and 133 deletions

View File

@@ -100,13 +100,15 @@ qboolean SNDDMA_Init( void )
return false;
}
SDL_AudioSpec desired, obtained;
memset( &desired, 0, sizeof( desired ) );
desired.freq = SOUND_DMA_SPEED;
desired.format = AUDIO_S16SYS;
desired.samples = 1024;
desired.channels = 2;
desired.callback = SDL_SoundCallback;
SDL_AudioSpec obtained;
SDL_AudioSpec desired =
{
.freq = SOUND_DMA_SPEED,
.format = AUDIO_S16SYS,
.samples = 1024,
.channels = 2,
.callback = SDL_SoundCallback,
};
sdl_dev = SDL_OpenAudioDevice( NULL, 0, &desired, &obtained, 0 );

View File

@@ -74,7 +74,7 @@ Returns false if nothing is found.
*/
qboolean SNDDMA_Init( void )
{
SDL_AudioSpec desired, obtained;
SDL_AudioSpec obtained;
int samplecount;
// Modders often tend to use proprietary crappy solutions
@@ -117,12 +117,14 @@ qboolean SNDDMA_Init( void )
return false;
}
memset( &desired, 0, sizeof( desired ) );
desired.freq = SOUND_DMA_SPEED;
desired.format = AUDIO_S16SYS;
desired.samples = 1024;
desired.channels = 2;
desired.callback = SDL_SoundCallback;
SDL_AudioSpec desired =
{
.freq = SOUND_DMA_SPEED,
.format = AUDIO_S16SYS,
.samples = 1024,
.channels = 2,
.callback = SDL_SoundCallback,
};
sdl_dev = SDL_OpenAudioDevice( NULL, 0, &desired, &obtained, 0 );

View File

@@ -193,11 +193,12 @@ void SW_UnlockBuffer( void )
{
if( sw.renderer )
{
SDL_Rect src, dst;
src.x = src.y = 0;
src.w = sw.width;
src.h = sw.height;
dst = src;
SDL_Rect src =
{
.w = sw.width,
.h = sw.height,
};
SDL_Rect dst = src;
SDL_UnlockTexture(sw.tex);
SDL_SetTextureBlendMode(sw.tex, SDL_BLENDMODE_NONE);
@@ -213,11 +214,12 @@ void SW_UnlockBuffer( void )
// blit if blitting surface availiable
if( sw.surf )
{
SDL_Rect src, dst;
src.x = src.y = 0;
src.w = sw.width;
src.h = sw.height;
dst = src;
SDL_Rect src =
{
.w = sw.width,
.h = sw.height,
};
SDL_Rect dst = src;
SDL_UnlockSurface( sw.surf );
SDL_BlitSurface( sw.surf, &src, sw.win, &dst );
return;

View File

@@ -164,9 +164,6 @@ static void Wcon_SetInputText( const char *inputText )
static void Wcon_Clear_f( void )
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
SMALL_RECT scrollRect;
COORD scrollTarget;
CHAR_INFO fill;
if( host.type != HOST_DEDICATED )
return;
@@ -176,14 +173,20 @@ static void Wcon_Clear_f( void )
return;
}
scrollRect.Left = 0;
scrollRect.Top = 0;
scrollRect.Right = csbi.dwSize.X;
scrollRect.Bottom = csbi.dwSize.Y;
scrollTarget.X = 0;
scrollTarget.Y = (SHORT)(0 - csbi.dwSize.Y);
fill.Char.UnicodeChar = TEXT(' ');
fill.Attributes = csbi.wAttributes;
SMALL_RECT scrollRect =
{
.Right = csbi.dwSize.X,
.Bottom = csbi.dwSize.Y,
};
COORD scrollTarget =
{
.Y = (SHORT)(0 - csbi.dwSize.Y),
};
CHAR_INFO fill =
{
.Char.UnicodeChar = TEXT(' '),
.Attributes = csbi.wAttributes,
};
ScrollConsoleScreenBuffer( s_wcd.hOutput, &scrollRect, NULL, scrollTarget, &fill );
csbi.dwCursorPosition.X = 0;
@@ -379,11 +382,9 @@ static void Wcon_EventCharacter(char c)
static void Wcon_UpdateStatusLine( void )
{
COORD coord;
COORD coord = { 0 };
DWORD dwWritten;
coord.X = 0;
coord.Y = 0;
WORD wAttrib = g_color_table[5] | FOREGROUND_INTENSITY | BACKGROUND_INTENSITY;
FillConsoleOutputCharacter( s_wcd.hOutput, ' ', 80, coord, &dwWritten );