summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/g_admin.c8
-rw-r--r--src/game/g_buildable.c12
-rw-r--r--src/game/g_local.h1
-rw-r--r--src/game/g_maprotation.c12
4 files changed, 16 insertions, 17 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 24330aa2..c4d3c427 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -2053,9 +2053,7 @@ qboolean G_admin_changemap( gentity_t *ent )
if( trap_Argc( ) > 2 )
{
trap_Argv( 2, layout, sizeof( layout ) );
- if( !Q_stricmp( layout, "*BUILTIN*" ) ||
- trap_FS_FOpenFile( va( "layouts/%s/%s.dat", map, layout ),
- NULL, FS_READ ) > 0 )
+ if( G_LayoutExists( map, layout ) )
{
trap_Cvar_Set( "g_nextLayout", layout );
}
@@ -2713,9 +2711,7 @@ qboolean G_admin_restart( gentity_t *ent )
Q_stricmp( layout, "switchteams" ) &&
Q_stricmp( layout, "switchteamslock" ) )
{
- if( !Q_stricmp( layout, "*BUILTIN*" ) ||
- trap_FS_FOpenFile( va( "layouts/%s/%s.dat", map, layout ),
- NULL, FS_READ ) > 0 )
+ if( G_LayoutExists( map, layout ) )
{
trap_Cvar_Set( "g_nextLayout", layout );
}
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index a57a5adc..a5e64d36 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -4056,7 +4056,6 @@ set level.layout based on g_nextLayout, g_layouts or g_layoutAuto
*/
void G_LayoutSelect( void )
{
- char fileName[ MAX_OSPATH ];
char layouts[ ( MAX_CVAR_VALUE_STRING - 1 ) * 9 + 1 ];
char layouts2[ ( MAX_CVAR_VALUE_STRING - 1 ) * 9 + 1 ];
char *l;
@@ -4094,16 +4093,7 @@ void G_LayoutSelect( void )
if( !*s )
break;
- if( !Q_stricmp( s, "*BUILTIN*" ) )
- {
- Q_strcat( layouts, sizeof( layouts ), s );
- Q_strcat( layouts, sizeof( layouts ), " " );
- cnt++;
- continue;
- }
-
- Com_sprintf( fileName, sizeof( fileName ), "layouts/%s/%s.dat", map, s );
- if( trap_FS_FOpenFile( fileName, NULL, FS_READ ) > 0 )
+ if( G_LayoutExists( map, s ) )
{
Q_strcat( layouts, sizeof( layouts ), s );
Q_strcat( layouts, sizeof( layouts ), " " );
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 262eb138..a0a03405 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -1072,6 +1072,7 @@ qboolean G_MapRotationActive( void );
void G_InitMapRotations( void );
void G_ShutdownMapRotations( void );
qboolean G_MapExists( const char *name );
+qboolean G_LayoutExists( const char *map, const char *layout );
void G_ClearRotationStack( void );
void G_PerformMapRestart( void );
void G_PerformMapChange( const char *map );
diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c
index a25c9749..f45ee4ac 100644
--- a/src/game/g_maprotation.c
+++ b/src/game/g_maprotation.c
@@ -153,6 +153,18 @@ void G_PerformMapChange( const char *map )
/*
===============
+G_LayoutExists
+
+Check if a layout exists for a map
+===============
+*/
+qboolean G_LayoutExists( const char *map, const char *layout )
+{
+ return !Q_stricmp( layout, "*BUILTIN*" ) || trap_FS_FOpenFile( va( "layouts/%s/%s.dat", map, layout ), NULL, FS_READ ) > 0;
+}
+
+/*
+===============
G_RotationExists
Check if a rotation exists