summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTony J. White <tjw@tjw.org>2006-12-30 00:17:11 +0000
committerTony J. White <tjw@tjw.org>2006-12-30 00:17:11 +0000
commit9ed2e16fd1561c57275967569452678e860cfae7 (patch)
treee8fce6dd2e98e768cf0ca70353d822510ef8fd3c /src
parentefbd4de85142909a5e5d30ed7812666f095c68cd (diff)
* (bug 2973) allow '-' and '_' in layout names and check to make sure layouts
named in !map and !restart commands are valid names
Diffstat (limited to 'src')
-rw-r--r--src/game/g_admin.c45
-rw-r--r--src/game/g_svcmds.c2
2 files changed, 39 insertions, 8 deletions
diff --git a/src/game/g_admin.c b/src/game/g_admin.c
index 99a9a08b..f16c961a 100644
--- a/src/game/g_admin.c
+++ b/src/game/g_admin.c
@@ -1888,23 +1888,37 @@ qboolean G_admin_putteam( gentity_t *ent, int skiparg )
qboolean G_admin_map( gentity_t *ent, int skiparg )
{
char map[ MAX_QPATH ];
- char layout[ MAX_QPATH ];
+ char layout[ MAX_QPATH ] = { "" };
- if( G_SayArgc() < 2 + skiparg )
+ if( G_SayArgc( ) < 2 + skiparg )
{
ADMP( "^3!map: ^7usage: !map [map] (layout)\n" );
return qfalse;
}
G_SayArgv( skiparg + 1, map, sizeof( map ) );
- G_SayArgv( skiparg + 2, layout, sizeof( layout ) );
if( !trap_FS_FOpenFile( va( "maps/%s.bsp", map ), NULL, FS_READ ) )
{
ADMP( va( "^3!map: ^7invalid map name '%s'\n", map ) );
return qfalse;
}
- trap_Cvar_Set( "g_layouts", layout );
+
+ if( G_SayArgc( ) > 2 + skiparg )
+ {
+ G_SayArgv( skiparg + 2, layout, sizeof( layout ) );
+ if( trap_FS_FOpenFile( va( "layouts/%s/%s.dat", map, layout ),
+ NULL, FS_READ ) > 0 )
+ {
+ trap_Cvar_Set( "g_layouts", layout );
+ }
+ else
+ {
+ ADMP( va( "^3!map: ^7invalid layout name '%s'\n", layout ) );
+ return qfalse;
+ }
+ }
+
trap_SendConsoleCommand( EXEC_APPEND, va( "map %s", map ) );
AP( va( "print \"^3!map: ^7map '%s' started by %s %s\n\"", map,
( ent ) ? ent->client->pers.netname : "console",
@@ -2620,10 +2634,27 @@ qboolean G_admin_rename( gentity_t *ent, int skiparg )
qboolean G_admin_restart( gentity_t *ent, int skiparg )
{
- char layout[ MAX_CVAR_VALUE_STRING ];
+ char layout[ MAX_CVAR_VALUE_STRING ] = { "" };
+
+ if( G_SayArgc( ) > 1 + skiparg )
+ {
+ char map[ MAX_QPATH ];
+
+ trap_Cvar_VariableStringBuffer( "mapname", map, sizeof( map ) );
+ G_SayArgv( skiparg + 1, layout, sizeof( layout ) );
+
+ if( trap_FS_FOpenFile( va( "layouts/%s/%s.dat", map, layout ),
+ NULL, FS_READ ) > 0 )
+ {
+ trap_Cvar_Set( "g_layouts", layout );
+ }
+ else
+ {
+ ADMP( va( "^3!restart: ^7layout '%s' does not exist\n", layout ) );
+ return qfalse;
+ }
+ }
- G_SayArgv( skiparg + 1, layout, sizeof( layout ) );
- trap_Cvar_Set( "g_layouts", layout );
trap_SendConsoleCommand( EXEC_APPEND, "map_restart" );
AP( va( "print \"^3!restart: ^7map restarted by %s %s\n\"",
( ent ) ? ent->client->pers.netname : "console",
diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c
index 6ede44be..be2a4da6 100644
--- a/src/game/g_svcmds.c
+++ b/src/game/g_svcmds.c
@@ -502,7 +502,7 @@ void Svcmd_LayoutSave_f( void )
{
if( ( *s >= '0' && *s <= '9' ) ||
( *s >= 'a' && *s <= 'z' ) ||
- ( *s >= 'A' && *s <= 'Z' ) )
+ ( *s >= 'A' && *s <= 'Z' ) || *s == '-' || *s == '_' )
{
str2[ i++ ] = *s;
str2[ i ] = '\0';