diff --git a/pkg/unvanquished_src.dpkdir/ui/server_create.rml b/pkg/unvanquished_src.dpkdir/ui/server_create.rml index 5809ed70621..8a09d97b2ac 100644 --- a/pkg/unvanquished_src.dpkdir/ui/server_create.rml +++ b/pkg/unvanquished_src.dpkdir/ui/server_create.rml @@ -60,7 +60,7 @@ - +

Map

diff --git a/src/cgame/cg_rocket_datasource.cpp b/src/cgame/cg_rocket_datasource.cpp index 22516e99fdc..ee94617d98d 100644 --- a/src/cgame/cg_rocket_datasource.cpp +++ b/src/cgame/cg_rocket_datasource.cpp @@ -34,6 +34,8 @@ Maryland 20850 USA. #include "cg_local.h" +static Cvar::Cvar g_defaultMap("g_defaultMap", "default map to play", Cvar::ARCHIVE, "plat23"); + static bool AddToServerList( const char *name, const char *label, int clients, int bots, int ping, int maxClients, char *mapName, char *addr, int netSrc ) { server_t *node; @@ -1119,16 +1121,30 @@ static void CG_Rocket_BuildMapList( const char* ) Rocket_DSClearTable( "mapList", "default" ); CG_LoadMapList(); + rocketInfo.data.mapIndex = -1; + for ( size_t i = 0; i < rocketInfo.data.mapList.size(); ++i ) { char buf[ MAX_INFO_STRING ] = { 0 }; + + Str::StringRef mapLoadName = rocketInfo.data.mapList[ i ].mapLoadName; + Info_SetValueForKey( buf, "num", std::to_string( i ).c_str(), false ); - Info_SetValueForKey( buf, "mapName", rocketInfo.data.mapList[ i ].mapLoadName.c_str(), false ); - Info_SetValueForKey( buf, "mapLoadName", rocketInfo.data.mapList[ i ].mapLoadName.c_str(), false ); + Info_SetValueForKey( buf, "mapName", mapLoadName.c_str(), false ); + Info_SetValueForKey( buf, "mapLoadName", mapLoadName.c_str(), false ); + + if ( mapLoadName == g_defaultMap.Get() ) + { + rocketInfo.data.mapIndex = i; + } Rocket_DSAddRow( "mapList", "default", buf ); } + if ( rocketInfo.data.mapIndex == -1 && !rocketInfo.data.mapList.empty() ) + { + rocketInfo.data.mapIndex = 0; + } } static void CG_Rocket_CleanUpMapList( const char* ) @@ -1137,7 +1153,26 @@ static void CG_Rocket_CleanUpMapList( const char* ) static void CG_Rocket_SetMapListIndex( const char*, int index ) { - rocketInfo.data.mapIndex = index; + int size = int( rocketInfo.data.mapList.size() ); + + if ( index >= 0 && index < size ) + { + rocketInfo.data.mapIndex = index; + g_defaultMap.Set( rocketInfo.data.mapList[ index ].mapLoadName ); + } + else + { + Log::Warn( "Map list index %d is out of range [0, %d[", index, size ); + } +} + +static int CG_Rocket_GetMapListIndex( const char* ) +{ + if ( rocketInfo.data.mapList.size() != 0 ) + { + CG_Rocket_BuildMapList( nullptr ); + } + return rocketInfo.data.mapIndex; } @@ -1841,7 +1876,7 @@ static const dataSourceCmd_t dataSourceCmdList[] = { "humanBuildList", &CG_Rocket_BuildHumanBuildList, &nullSortFunc, &nullCleanFunc, &nullSetFunc, &nullFilterFunc, &nullExecFunc, &nullGetFunc }, { "humanSpawnItems", &CG_Rocket_BuildHumanSpawnItems, &nullSortFunc, CG_Rocket_CleanUpHumanSpawnItems, &CG_Rocket_SetHumanSpawnItems, &nullFilterFunc, &CG_Rocket_ExecHumanSpawnItems, &nullGetFunc }, { "languages", &CG_Rocket_BuildLanguageList, &nullSortFunc, &CG_Rocket_CleanUpLanguageList, &CG_Rocket_SetLanguageListLanguage, &nullFilterFunc, &nullExecFunc, &CG_Rocket_GetLanguageListIndex }, - { "mapList", &CG_Rocket_BuildMapList, &nullSortFunc, &CG_Rocket_CleanUpMapList, &CG_Rocket_SetMapListIndex, &nullFilterFunc, &nullExecFunc, &nullGetFunc }, + { "mapList", &CG_Rocket_BuildMapList, &nullSortFunc, &CG_Rocket_CleanUpMapList, &CG_Rocket_SetMapListIndex, &nullFilterFunc, &nullExecFunc, &CG_Rocket_GetMapListIndex }, { "modList", &CG_Rocket_BuildModList, &nullSortFunc, &CG_Rocket_CleanUpModList, &CG_Rocket_SetModListMod, &nullFilterFunc, &nullExecFunc, &nullGetFunc }, { "playerList", &CG_Rocket_BuildPlayerList, &CG_Rocket_SortPlayerList, &CG_Rocket_CleanUpPlayerList, &CG_Rocket_SetPlayerListPlayer, &nullFilterFunc, &nullExecFunc, &nullGetFunc }, { "resolutions", &CG_Rocket_BuildResolutionList, &nullSortFunc, &CG_Rocket_CleanUpResolutionList, &CG_Rocket_SetResolutionListResolution, &nullFilterFunc, &nullExecFunc, &CG_Rocket_GetResolutionListIndex},