Skip to content
Permalink
Browse files

use default or builtin layout instead of *BUILTIN* if available

  • Loading branch information
Gireen authored and illwieckz committed Dec 24, 2019
1 parent c50fb44 commit 7a98c4e3de547e1ea7d7672274745eda42dda690
Showing with 20 additions and 3 deletions.
  1. +1 −1 src/sgame/sg_admin.cpp
  2. +19 −2 src/sgame/sg_buildable.cpp
@@ -4268,7 +4268,7 @@ bool G_admin_restart( gentity_t *ent )
admin_log( teampref );

// cvars
trap_Cvar_Set( "g_layouts", builtin ? S_BUILTIN_LAYOUT : layout );
trap_Cvar_Set( "g_layouts", layout );
trap_Cvar_Set( "g_mapRestarted", "y" );

// handle the flag
@@ -2229,6 +2229,7 @@ int G_LayoutList( const char *map, char *list, int len )
void G_LayoutSelect()
{
char fileName[ MAX_OSPATH ];
char fileName2[ MAX_OSPATH ];
char layouts[ MAX_CVAR_VALUE_STRING ];
char layouts2[ MAX_CVAR_VALUE_STRING ];
const char *layoutPtr;
@@ -2255,10 +2256,26 @@ void G_LayoutSelect()
G_LayoutList( map, layouts, sizeof( layouts ) );
}

// no layout specified, use the map's builtin layout
// no layout specified
if ( !layouts[ 0 ] )
{
return;
Com_sprintf( fileName, sizeof( fileName ), "layouts/%s/default.dat", map );
Com_sprintf( fileName2, sizeof( fileName ), "layouts/%s/builtin.dat", map );

//use default layout if available
if ( trap_FS_FOpenFile( fileName, nullptr, fsMode_t::FS_READ ) > 0 )
{
strcpy( layouts, "default" );
}
else if ( trap_FS_FOpenFile( fileName2, nullptr, fsMode_t::FS_READ ) > 0 )
{
strcpy( layouts, "builtin" );
}
else
{
//use the map's builtin layout
return;
}
}

Q_strncpyz( layouts2, layouts, sizeof( layouts2 ) );

0 comments on commit 7a98c4e

Please sign in to comment.
You can’t perform that action at this time.