From 639639c22d45eda949809446e4c29e0ed4c7d290 Mon Sep 17 00:00:00 2001 From: /dev/humancontroller Date: Thu, 9 Mar 2017 08:51:38 +0100 Subject: rename g_layouts to g_nextLayout; add a different set of cvars: g_layouts, g_layouts2, ..., g_layouts9 also remove the latching property --- src/game/g_admin.c | 4 ++-- src/game/g_buildable.c | 15 ++++++++++----- src/game/g_local.h | 3 ++- src/game/g_main.c | 14 ++++++++++++-- src/game/g_maprotation.c | 6 +++--- src/game/g_svcmds.c | 4 ++-- 6 files changed, 31 insertions(+), 15 deletions(-) (limited to 'src/game') diff --git a/src/game/g_admin.c b/src/game/g_admin.c index 25e63f46..2d6aeaba 100644 --- a/src/game/g_admin.c +++ b/src/game/g_admin.c @@ -2057,7 +2057,7 @@ qboolean G_admin_changemap( gentity_t *ent ) trap_FS_FOpenFile( va( "layouts/%s/%s.dat", map, layout ), NULL, FS_READ ) > 0 ) { - trap_Cvar_Set( "g_layouts", layout ); + trap_Cvar_Set( "g_nextLayout", layout ); } else { @@ -2717,7 +2717,7 @@ qboolean G_admin_restart( gentity_t *ent ) trap_FS_FOpenFile( va( "layouts/%s/%s.dat", map, layout ), NULL, FS_READ ) > 0 ) { - trap_Cvar_Set( "g_layouts", layout ); + trap_Cvar_Set( "g_nextLayout", layout ); } else { diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 1425e539..a57a5adc 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -4051,25 +4051,30 @@ int G_LayoutList( const char *map, char *list, int len ) ============ G_LayoutSelect -set level.layout based on g_layouts or g_layoutAuto +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 ]; - char layouts2[ MAX_CVAR_VALUE_STRING ]; + char layouts[ ( MAX_CVAR_VALUE_STRING - 1 ) * 9 + 1 ]; + char layouts2[ ( MAX_CVAR_VALUE_STRING - 1 ) * 9 + 1 ]; char *l; char map[ MAX_QPATH ]; char *s; int cnt = 0; int layoutNum; - Q_strncpyz( layouts, g_layouts.string, sizeof( layouts ) ); + Q_strncpyz( layouts, g_nextLayout.string, sizeof( layouts ) ); + if( !layouts[ 0 ] ) + { + for( layoutNum = 0; layoutNum < 9; ++layoutNum ) + Q_strcat( layouts, sizeof( layouts ), g_layouts[ layoutNum ].string ); + } trap_Cvar_VariableStringBuffer( "mapname", map, sizeof( map ) ); // one time use cvar - trap_Cvar_Set( "g_layouts", "" ); + trap_Cvar_Set( "g_nextLayout", "" ); // pick an included layout at random if no list has been provided if( !layouts[ 0 ] && g_layoutAuto.integer ) diff --git a/src/game/g_local.h b/src/game/g_local.h index ea12e342..693b5bb1 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -1176,7 +1176,8 @@ extern vmCvar_t g_shove; extern vmCvar_t g_mapConfigs; -extern vmCvar_t g_layouts; +extern vmCvar_t g_nextLayout; +extern vmCvar_t g_layouts[ 9 ]; extern vmCvar_t g_layoutAuto; extern vmCvar_t g_emoticonsAllowedInNames; diff --git a/src/game/g_main.c b/src/game/g_main.c index 4858c75c..4fd2a04e 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -125,7 +125,8 @@ vmCvar_t g_sayAreaRange; vmCvar_t g_floodMaxDemerits; vmCvar_t g_floodMinTime; -vmCvar_t g_layouts; +vmCvar_t g_nextLayout; +vmCvar_t g_layouts[ 9 ]; vmCvar_t g_layoutAuto; vmCvar_t g_emoticonsAllowedInNames; @@ -257,7 +258,16 @@ static cvarTable_t gameCvarTable[ ] = { &g_mapConfigs, "g_mapConfigs", "", CVAR_ARCHIVE, 0, qfalse }, { NULL, "g_mapConfigsLoaded", "0", CVAR_ROM, 0, qfalse }, - { &g_layouts, "g_layouts", "", CVAR_LATCH, 0, qfalse }, + { &g_nextLayout, "g_nextLayout", "", 0, 0, qfalse }, + { &g_layouts[ 0 ], "g_layouts", "", 0, 0, qfalse }, + { &g_layouts[ 1 ], "g_layouts2", "", 0, 0, qfalse }, + { &g_layouts[ 2 ], "g_layouts3", "", 0, 0, qfalse }, + { &g_layouts[ 3 ], "g_layouts4", "", 0, 0, qfalse }, + { &g_layouts[ 4 ], "g_layouts5", "", 0, 0, qfalse }, + { &g_layouts[ 5 ], "g_layouts6", "", 0, 0, qfalse }, + { &g_layouts[ 6 ], "g_layouts7", "", 0, 0, qfalse }, + { &g_layouts[ 7 ], "g_layouts8", "", 0, 0, qfalse }, + { &g_layouts[ 8 ], "g_layouts9", "", 0, 0, qfalse }, { &g_layoutAuto, "g_layoutAuto", "1", CVAR_ARCHIVE, 0, qfalse }, { &g_emoticonsAllowedInNames, "g_emoticonsAllowedInNames", "1", CVAR_LATCH|CVAR_ARCHIVE, 0, qfalse }, diff --git a/src/game/g_maprotation.c b/src/game/g_maprotation.c index 0487079c..e6d773e8 100644 --- a/src/game/g_maprotation.c +++ b/src/game/g_maprotation.c @@ -891,10 +891,10 @@ static void G_IssueMapChange( int index, int rotation ) node_t *node = mapRotations.rotations[ rotation ].nodes[ index ]; map_t *map = &node->u.map; - // allow a manually defined g_layouts setting to override the maprotation - if( !g_layouts.string[ 0 ] && map->layouts[ 0 ] ) + // allow a manually defined g_nextLayout setting to override the maprotation + if( !g_nextLayout.string[ 0 ] && map->layouts[ 0 ] ) { - trap_Cvar_Set( "g_layouts", map->layouts ); + trap_Cvar_Set( "g_nextLayout", map->layouts ); } G_PerformMapChange( map->name ); diff --git a/src/game/g_svcmds.c b/src/game/g_svcmds.c index 952c6801..c2d61ec3 100644 --- a/src/game/g_svcmds.c +++ b/src/game/g_svcmds.c @@ -249,7 +249,7 @@ Svcmd_LayoutLoad_f layoutload [ [ [