Skip to content

Commit b2133dd

Browse files
committed
menus: PlayerSetup: initialize logo texture handle and color with something valid by default
1 parent 479010a commit b2133dd

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

menus/PlayerSetup.cpp

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -364,55 +364,60 @@ void CMenuPlayerSetup::UpdateModel()
364364
// just force display string and do nothing
365365
if( !mdl )
366366
{
367-
model.ForceDisplayString( EngFuncs::GetCvarString( "model" ) );
367+
model.ForceDisplayString( EngFuncs::GetCvarString( "model" ));
368368
return;
369369
}
370370

371371
snprintf( image, sizeof( image ), "models/player/%s/%s.bmp", mdl, mdl );
372372
view.hPlayerImage = EngFuncs::PIC_Load( image, PIC_KEEP_SOURCE );
373-
374373
ApplyColorToImagePreview();
374+
375375
EngFuncs::CvarSetString( "model", mdl );
376-
if( !strcmp( mdl, "player" ) )
376+
if( !strcmp( mdl, "player" ))
377377
strcpy( image, "models/player.mdl" );
378378
else
379-
snprintf( image, sizeof(image), "models/player/%s/%s.mdl", mdl, mdl );
379+
snprintf( image, sizeof( image ), "models/player/%s/%s.mdl", mdl, mdl );
380+
380381
if( view.ent )
381382
EngFuncs::SetModel( view.ent, image );
382383
}
383384

384385
void CMenuPlayerSetup::UpdateLogo()
385386
{
386-
char filename[1024];
387-
int pos = logo.GetCurrentValue();
387+
const int pos = logo.GetCurrentValue();
388+
389+
logoImage.color = &g_LogoColors[0];
390+
logoColor.SetCurrentValue( L( g_LogoColors[0].name ));
391+
logoColor.SetGrayed( true );
388392

389393
if( pos < 0 )
394+
{
395+
logoImage.hImage = 0;
390396
return;
397+
}
391398

392-
logosModel.GetFullPath( filename, sizeof( filename ), pos );
393-
logoImage.hImage = EngFuncs::PIC_Load( filename, 0 );
394-
if( logosModel.IsPng( pos ))
399+
char filename[1024];
400+
const int temp = logosModel.GetFullPath( filename, sizeof( filename ), pos );
401+
if(( temp < 0 ) || ( temp > sizeof( filename )))
395402
{
396-
logoImage.color = &g_LogoColors[0];
397-
logoColor.SetGrayed( true );
403+
logoImage.hImage = 0;
404+
return;
398405
}
399-
else
406+
407+
logoImage.hImage = EngFuncs::PIC_Load( filename, 0 );
408+
409+
if( !logosModel.IsPng( pos ))
400410
{
401411
CBMP *bmpFile = CBMP::LoadFile( filename );
402412
if( bmpFile->GetBitmapHdr()->bitsPerPixel == 8 )
403413
{
404414
ApplyColorToLogoPreview();
405415
logoColor.SetGrayed( false );
406416
}
407-
else
408-
{
409-
logoImage.color = &g_LogoColors[0];
410-
logoColor.SetGrayed( true );
411-
}
412417
delete bmpFile;
413418
}
414419

415-
EngFuncs::CvarSetString( "cl_logofile", logo.GetCurrentString() );
420+
EngFuncs::CvarSetString( "cl_logofile", logo.GetCurrentString( ));
416421
logoColor.WriteCvar();
417422
}
418423

0 commit comments

Comments
 (0)